package com.example.rental.service.impl;


import com.example.rental.entity.Oder;
import com.example.rental.entity.dto.OderDto;
import com.example.rental.mapper.OderMapper;
import com.example.rental.result.Result;
import com.example.rental.service.OderService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class OderServiceImpl implements OderService {
    @Resource
    private OderMapper oderMapper;
    @Override
    public Result getOders(OderDto oderDto) {
        PageHelper.startPage(oderDto.getPage(), oderDto.getLimit());

        List<Oder> list = oderMapper.getOders(oderDto);

        Page page = (Page) list;
        Result result = Result.ok(list);
        result.setCount(page.getTotal());

        return result;
    }
    @Override
    public Integer deleteOderByOderid(Integer orderid) {
        return oderMapper.deleteOderByOderid(orderid);
    }
    @Override
    public void addOder(OderDto oderDto){oderMapper.addOder(oderDto);};

    @Override
    public List<Integer> selectStatusByUserId(Integer id) {
        return oderMapper.selectStatusByUserId(id);
    }
    @Override
    public List<Integer> selectStatusByHouseId(Integer houseid) {
        return oderMapper.selectStatusByHouseId(houseid);
    }
    @Override
    public void updateOder(Oder oder){oderMapper.updateOder(oder);};
    @Override
    public void updateAllOder(Oder oder){oderMapper.updateAllOder(oder);};
}
